<template>
  <div>
    <h1>SonComp - {{ money }}</h1>
    <button @click="costMoney">花钱</button>
  </div>
</template>

<script>
export default {
  props: {
    money: {
      type: Number,
      required: true
    },
    fn: {
      type: Function,
      default: () => {}
    }
  },
  methods: {
    costMoney() {
      this.fn({
        results: [{ id: 1, name: '1' }, { id: 2, name: '2' }],
        header: ['1', 2, 3]
      })
      // .sync语法糖 必须事件名要update:xxx xxx就是放权给你的字段
      this.$emit('update:money', this.money - 10)
    }
  }
}
</script>

<style>

</style>
